package com.hzhjhh.view.manageView.menus.purchase;


import javax.swing.*;

import org.apache.ibatis.session.SqlSession;

import com.hzhjhh.init.dialog.Mytable;
import com.hzhjhh.mapper.MerchandiseMapper;
import com.hzhjhh.util.DBUtils;
import com.hzhjhh.util.TimerScheduleTaskUtil;
import com.hzhjhh.view.manageView.menus.purchase.constant.ShowConstants;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.ClearAllBt;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.DeleteBt;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.EnsureBt;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.MerchandiseCode;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.MerchandiseName;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.OrderDate;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.PaymentTerm;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.PricePerOne;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.PurchaseAmt;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.PurchaseDept;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.PurchaseNum;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.QuitBt;
import com.hzhjhh.view.manageView.menus.purchase.purchaseOrder.SubmitBt;

import lombok.Getter;
import lombok.Setter;

import java.awt.*;
import java.util.Vector;

/**
 * 菜单栏初始化-采购-采购表弹出框
 * 
 * @author 12083
 *
 */
@Getter
@Setter
public class PurchaseOrderDialog extends JDialog {
    JPanel panel1 = new JPanel();
    JTextField txfMerchandiseCode = MerchandiseCode.txfInit(this);
    JTextField txfMerchandiseName = MerchandiseName.txfInit();
    JTextField txfPurchaseDept = PurchaseDept.txfInit();
    JTextField txfPurchaseNum = PurchaseNum.txfInit(this);
    JTextField txfPricePerOne = PricePerOne.txfInit();
    JLabel lbMerchandiseCode = MerchandiseCode.lbInit();
    JLabel lbMerchandiseName = MerchandiseName.lbInit();
    JLabel lbPurchaseDept = PurchaseDept.lbInit();
    JLabel lbPurchaseNum = PurchaseNum.lbInit();
    JLabel lbPricePerOne = PricePerOne.lbInit();
    JTextField txfAmt = PurchaseAmt.txfInit();
    JLabel lbPurchaseAmt = PurchaseAmt.lbInit();
    JTextField txfOrderDate = OrderDate.txfInit();
    JLabel lbOrderDate = OrderDate.lbInit();
    JLabel jLabel11 = new JLabel();
    JTextField txfPaymentTerm = new JTextField();
    JLabel lbPaymentTerm = PaymentTerm.lbInit();
    JScrollPane jScrollPane1 = new JScrollPane();
    JTable jTable1 = new JTable();
    JButton btEnsure = EnsureBt.btInit(this);
    JButton jButton2 = DeleteBt.btInit(this);
    JButton jButton3 = SubmitBt.btInit(this);
    JButton jButton4 = ClearAllBt.btInit(this);
    JButton jButton5 = QuitBt.btInit(this);
    
    /**
     * 展示列表-多行
     */
    Vector<Vector<String>> inserAll = new Vector<>();
    
    private MerchandiseMapper merchandiseMapper;
    
    private PurchaseOrderDialog(Frame owner, String title, boolean modal) {
        super(owner, title, modal);
        try {
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            jbInit();
            pack();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public PurchaseOrderDialog() {
        this(new Frame(), "Stock_Dialog", false);
        this.setSize(787, 550);
        this.setVisible(true);
		this.setLocation(150, 150);
		this.setTitle("采购单");
		// 初始化mapper
		mapperInit();
    }
    private void mapperInit() {
		SqlSession sqlSession = DBUtils.getSqlSession(true);
		merchandiseMapper = sqlSession.getMapper(MerchandiseMapper.class);
	}

    private void jbInit() throws Exception {
        panel1.setLayout(null);
        TimerScheduleTaskUtil.time2Show(txfOrderDate);

        jLabel11.setText("jLabel11");
        jLabel11.setBounds(61, 140, 75, 21);
        txfPaymentTerm.setBounds(676, 59, 90, 21);
        jScrollPane1.getViewport().setBackground(SystemColor.control);
        jScrollPane1.setBounds(14, 126, 765, 381);
        this.setForeground(Color.pink);
        panel1.setBackground(Color.pink);
        getContentPane().add(panel1);
        panel1.add(lbMerchandiseCode);
        panel1.add(lbPurchaseNum);
        panel1.add(lbPricePerOne);
        panel1.add(jScrollPane1);
        panel1.add(txfOrderDate);
        panel1.add(txfPaymentTerm);
        panel1.add(jButton5);
        panel1.add(btEnsure);
        panel1.add(jButton2);
        panel1.add(jButton3);
        panel1.add(jButton4);
        panel1.add(txfMerchandiseCode);
        panel1.add(txfPurchaseNum);
        panel1.add(lbMerchandiseName);
        panel1.add(txfPricePerOne);
        panel1.add(txfMerchandiseName);
        panel1.add(txfAmt);
        panel1.add(lbPurchaseDept);
        panel1.add(lbPurchaseAmt);
        panel1.add(txfPurchaseDept);
        panel1.add(lbOrderDate);
        panel1.add(lbPaymentTerm);

        jTable1 = Mytable.maketable(new Vector<>(), ShowConstants.PURCHASE_HEAD_NAME); //显示内容
        jScrollPane1.getViewport().add(jTable1); //把表装入容器
    }


}










